keepalived: only add content to config file if needed
authorFlorian Eckert <[email protected]>
Mon, 16 Dec 2024 14:35:12 +0000 (15:35 +0100)
committerFlorian Eckert <[email protected]>
Thu, 4 Sep 2025 06:34:13 +0000 (08:34 +0200)
Only add the first two pieces of information to the configuration file if
there is a valid '/etc/config/keepalived'.

Signed-off-by: Florian Eckert <[email protected]>
net/keepalived/files/keepalived.init

index c017a679f8547b5dc18a539cfa3e2a34d9981872..20535a4b54960c50b7f27ec53a25a858a5dde76e 100644 (file)
@@ -600,11 +600,6 @@ process_config() {
        local alt_config_file linkbeat_use_polling
 
        rm -f "$KEEPALIVED_CONF"
-
-       # First line
-       printf '! Configuration file for keepalived (autogenerated via init script)\n' > "$KEEPALIVED_CONF"
-       printf '! Written %s\n\n' "$(date +'%c')" >> "$KEEPALIVED_CONF"
-
        [ -f /etc/config/keepalived ] || return 0
        config_load 'keepalived'
        config_get alt_config_file globals alt_config_file
@@ -617,6 +612,10 @@ process_config() {
                return 0
        }
 
+       # First line
+       printf '! Configuration file for keepalived (autogenerated via init script)\n' > "$KEEPALIVED_CONF"
+       printf '! Written %s\n\n' "$(date +'%c')" >> "$KEEPALIVED_CONF"
+
        config_get_bool linkbeat_use_polling globals linkbeat_use_polling 0
        [ "$linkbeat_use_polling" -gt 0 ] && printf 'linkbeat_use_polling\n\n' >> "$KEEPALIVED_CONF"